package com.myGis.entities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="MYGIS_SIMPLE_FIELD", catalog="public")
public class SimpleField {
	
	@Id 
	@GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "SIMPLE_FIELD_ID", unique = true, nullable = false)
	private Long simpleFieldId;
	
	@Column(name = "NAME", nullable = false)
	private String name;
	
	@Column(name = "TYPE", nullable = false)
	private String type;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "LAYER_ID", nullable = false)
	private Layer layer;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "simpleField", cascade = CascadeType.ALL)
	private List<ValueField> valueFields;

	public SimpleField() {
		valueFields = new ArrayList<ValueField>();
	}
	
	/**
	 * @return the layer
	 */
	public Layer getLayer() {
		return layer;
	}

	/**
	 * @param layer the layer to set
	 */
	public void setLayer(Layer layer) {
		this.layer = layer;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the simpleFieldId
	 */
	public Long getSimpleFieldId() {
		return simpleFieldId;
	}

	/**
	 * @param simpleFieldId the simpleFieldId to set
	 */
	public void setSimpleFieldId(Long simpleFieldId) {
		this.simpleFieldId = simpleFieldId;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the valueFields
	 */
	public List<ValueField> getValueFields() {
		return valueFields;
	}

	/**
	 * @param valueFields the valueFields to set
	 */
	public void setValueFields(List<ValueField> valueFields) {
		this.valueFields = valueFields;
	}
	
}
